/*
 * @(#)TestFireRequestHandler.java
 *
 *
 *
 * ver 1.0 Aug 30, 2007 ggranum
 */
package org.testfire.agent.handlers;

import org.testfire.agent.httpserver.RequestHandler;
import org.testfire.agent.httpserver.Request;
import org.testfire.agent.httpserver.Response;

// eof: TestFireRequestHandler.java
public class PingRequestHandler implements RequestHandler
{

    public PingRequestHandler()
    {

    }

    public synchronized void handleRequest( Request request, Response responseWriter )
    {
        System.out.println("Ping requested.");
        responseWriter.putParameter( "received_at", String.valueOf( System.currentTimeMillis() ) );
        hiDone();
    }

    public boolean shouldHandleRequest( Request request )
    {
        return request.getUrl().endsWith( "action.ping" );
    }

    public synchronized void hiDone()
    {
        this.notify();
    }
}